<%@ page import="service.BookService" %>
<%@ page import="model.Book" %>
<%@ page import="java.util.List" %>
<%@ page import="model.User" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: deng
  Date: 2021/12/11
  Time: 10:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" +
                request.getServerPort() + path + "/";
    %>
    <base href="<%=basePath%>">
    <title>图书信息</title>
    <link rel="stylesheet" href="<%=basePath%>css/bootstrap.min.css">
    <%--    <script src="../js/jquery-3.3.1.min.js"></script>--%>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <%--    <script src="../js/bootstrap.min.js"></script>--%>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        body{
            margin: 0 10px 0 10px;
            padding: 0;
            height: 100%;
        }
        .form_body{
            display: flex;
            justify-content: flex-start;
            padding: 20px;
        }
        .form_item{
            width: 20%;
        }
        td,th{
            text-align: center;
        }
    </style>
</head>
<body>
<form  role="form" method="get" action="../QueryOBook">
    <div class="form_body">
        <div class="form_item">用户名：<input type="text" name="name" id="name" autocomplete="off" required=""></div>
        <%--            <div class="form_item">电话号码：<input type="text" name="tel" autocomplete="off" ></div>--%>
        <input type="submit" value="查询" name="query">
        <button><a href="main/bookinfo.jsp">返回</a></button>
    </div>
</form>
<button class="btn" data-toggle="modal" data-target="#addModal">
    添加book
</button>

<%--表格内容--%>
<table class="table table-bordered table-hover" style="width: 100%">
    <%--    <caption>边框表格布局</caption>--%>
    <thead>
    <tr>
        <th>ID</th>
        <th>图书名称</th>
        <th>图书价格</th>
        <th>图书ISBN</th>
        <th>图书编号</th>
        <th>图书标签</th>
        <th>图书作者</th>
        <th>图书销量</th>
        <th>图书简介</th>
        <th>图书数量</th>
        <th>出版社</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <% request.setCharacterEncoding("utf-8");%>
    <%
        String name = request.getParameter("name");
        BookService bookService = new BookService();
        List<Book> booklist;
        booklist = bookService.QueryBookInfoByName(name);
        int i = 0;
        for(Book book:booklist){
    %>
    <tr>
        <td><%=i++%></td>
        <td><%=book.getBk_name()%></td>
        <td><%=book.getBk_price()%></td>
        <td><%=book.getBk_isbn()%></td>
        <td><%=book.getBk_id()%></td>
        <td><%=book.getBk_lables()%></td>
        <td><%=book.getBk_a_name()%></td>
        <td><%=book.getBk_sales()%></td>
        <td><%=book.getBk_introduction()%></td>
        <td><%=book.getBk_nums()%></td>
        <td><%=book.getBk_public()%></td>
        <td>
            <button class="btn" data-toggle="modal" data-target="#myModal">修改</button>
            <button><a href="<%=basePath%>/deleteBook?name=<%=book.getBk_name()%>">删除</a></button></td>
    </tr>
    <%}%>
    </tbody>
</table>
<!-- 新增Book模态框（Modal） -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="addModalLabel">
                    新增Book
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" action="<%=basePath%>addBook" method="post">
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_name"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书价格</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_price"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书ISBN</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_isbn"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书编号</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_id"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书标签</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_lables"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书作者</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_a_name"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书销量</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_sales"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书简介</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_introduction"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书数量</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_nums"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">出版社</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_public"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                        </button>
                        <input type="submit" class="btn btn-primary" value="添加" />
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 修改信息模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="">
                    新增Book
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" action="<%=basePath%>updatebook" method="post">
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_name"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书价格</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_price"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书ISBN</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_isbn"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书编号</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_id"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书标签</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_lables"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书作者</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_a_name"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书销量</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_sales"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书简介</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_introduction"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">图书数量</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_nums"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label color-white">出版社</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="bk_public"  placeholder="请输入图书名称" autocomplete="off" required>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                        </button>
                        <input type="submit" class="btn btn-primary" value="添加" />
                    </div>
                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    document.getElementById("reset").onclick=function(){
        console.log("重置");
        location.reload();
    };
</script>
</body>
</html>
